echo "IPingus6 - Penetrate the Internet!"
echo "=================================="
echo "Choose DDNS mode (1 - freedns.afraid.org | 2 - duckdns.org (simpler & faster) | 3 - CloudFlare (proprietary E-Corp service.) ):"
read dnsmode
git clone https://notabug.org/IvanGorinich/Miredo && cd Miredo && ./autogen.sh && ./configure && make && sudo make install
cd ..
rm -rf miredo
mkdir ~/ipingus6
if [ "$dnsmode" -eq "1" ]; then
    echo "Enter freedns.afraid.org Ditect URL Token (ex: a3cwNHRRYmU4gnVlOU14lrfOR1NiSXBaOjE5ODY4ODcy):"
    read token
    sudo echo $token > ~/ipingus6/token.conf
    sudo cp script.sh ~/ipingus6/ipingus6.sh
elif [ "$dnsmode" -eq "2" ]; then
    echo "Enter duckdns.org Token:"
    read token
    echo "Enter duckdns.org subdomain:"
    read subdomain
    sudo echo $token > ~/ipingus6/token.conf
    sudo echo $subdomain > ~/ipingus6/subdomain.conf
    sudo cp script2.sh ~/ipingus6/ipingus6.sh
elif [ "$dnsmode" -eq "3" ]; then
	echo "Enter CloudFlare Zone ID:"
    read zone
    echo "Enter CloudFlare Global API Key:"
    read authkey
    echo "Enter Email:"
    read email
    echo "Enter Domain:"
    read domain
    sudo echo $zone > ~/ipingus6/zone.conf
    sudo echo $authkey > ~/ipingus6/authkey.conf
    sudo echo $email > ~/ipingus6/email.conf
    sudo echo $domain > ~/ipingus6/domain.conf
    sudo cp script3.sh ~/ipingus6/ipingus6.sh
fi
chmod +x ~/ipingus6/ipingus6.sh
crontab -l | { cat; echo "*/10 * * * * ~/ipingus6/ipingus6.sh"; } | crontab -
crontab -l | { cat; echo "@reboot ~/ipingus6/ipingus6.sh"; } | crontab -
echo "=================================="
echo "IPingUS6 installed to ~/ipingus6. Now you need to reboot!"